package com.ruoyi.web.controller.pc;


import com.ruoyi.business.domain.WmsInPlanDetail;
import com.ruoyi.business.service.IWmsInPlanDetailService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 入库计划详情管理 Controller
 *
 * @author patton
 * @date 2023-07-16
 */
@RestController
@RequestMapping("/business/inPlanDetail")
public class WmsInPlanDetailController extends BaseController {

    @Autowired
    private IWmsInPlanDetailService wmsInPlanDetailService;

    /**
     * @Description: 列表
     * @author yunlong
     */
    @ApiOperation(value = "列表")
    @GetMapping("list")
    @CrossOrigin
    public TableDataInfo queryList(WmsInPlanDetail info) {
        startPage();
        List<WmsInPlanDetail> list = wmsInPlanDetailService.selectWmsInPlanDetailList(info);
        return getDataTable(list);
    }

    /**
     * @Description: 列表
     * @author yunlong
     */
    @ApiOperation(value = "列表")
    @GetMapping("queryAllList")
    @CrossOrigin
    public AjaxResult queryAllList(WmsInPlanDetail info) {
        List<WmsInPlanDetail> list = wmsInPlanDetailService.selectWmsInPlanDetailList(info);
        return AjaxResult.success(list);
    }

    /**
     * 新增
     */
    @Log(title = "新增", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody WmsInPlanDetail info)
    {
        return toAjax(wmsInPlanDetailService.insertWmsInPlanDetail(info));
    }

    /**
     * 编辑
     */
    @Log(title = "编辑", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody WmsInPlanDetail info)
    {
        return toAjax(wmsInPlanDetailService.updateWmsInPlanDetail(info));
    }

    /**
     * 删除
     */
    @Log(title = "删除", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody WmsInPlanDetail info)
    {
        return toAjax(wmsInPlanDetailService.deleteWmsInPlanDetailById(info.getId()));
    }

    /**
     * 详情接口
     */
    @Log(title = "详情")
    @GetMapping("/getDetail")
    @CrossOrigin
    public AjaxResult getDetail(WmsInPlanDetail info)
    {
        List<WmsInPlanDetail> list = wmsInPlanDetailService.selectWmsInPlanDetailList(info);
        return AjaxResult.success(list.get(0));
    }

}
